<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>MockObjectManager_ (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>

  <script type="text/javascript" src="//www.google.com/jsapi"></script>
  <script type="text/javascript">
     google.load("visualization", "1", {packages:["orgchart"]});
     var _loadingVisualizations = true;
  </script>

  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
        <span class="fn">labs.mock.MockObjectManager_</span>
        <span>Extends</span>
        <span class="fn-name">
          <a href="class_goog_labs_mock_MockManager_.html">
          goog.labs.mock.MockManager_
</a>
        </span>
</div>

<div class="g-section g-tpl-75-25">
  <div class="g-unit g-first" id="description">
    Sets up mock for the given object (or class), stubbing out all the defined
methods. By default, all stubs return <code>undefined</code>, though stubs can be
later defined using <code>goog.labs.mock.when</code>.
  </div>


        <div class="g-unit" id="useful-links">
          <div class="title">Useful links</div>
          <ol>
            <li><a href="closure_goog_labs_mock_mock.js.source.html"><span class='source-code-link'>Source Code</span></a></li>
            <li><a href="http://code.google.com/p/closure-library/source/browse/closure/goog/labs/mock/mock.js">Git</a></li>
          </ol>
        </div>
</div>






<h2 class="g-first">Inheritance</h2>
<div class='gviz-org-chart-container goog-inline-block'>
<table class='gviz-org-chart' style='display:none'>
  <tr><td><span class="type"><a href="class_goog_labs_mock_MockManager_.html">goog.labs.mock.MockManager_</a></span></td><td></td></tr>
  <tr><td>goog.labs.mock.MockObjectManager_</td><td><span class="type"><a href="class_goog_labs_mock_MockManager_.html">goog.labs.mock.MockManager_</a></span></td></tr>
</table>
</div>
<div class='gviz-org-chart-container goog-inline-block'>
<table class='gviz-org-chart' style='display:none'>
      <tr><td><span class="type"><a href="class_goog_labs_mock_MockSpyManager_.html">goog.labs.mock.MockSpyManager_</a></span></td><td>goog.labs.mock.MockObjectManager_</td></tr>
  </table>
</div>




  <h2>Constructor</h2>
      <div class="fn-constructor">
    goog.labs.mock.MockObjectManager_(<span><span class="arg">objOrClass</span></span>)
  </div>

   <h3>Parameters</h3>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">objOrClass</span>
        : <div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span></div>
        <div class="entryOverview">The object or class to set up the mock for. A class is a constructor function.</div>
     </td>
   </tr>
  </table>


<h2>Instance Methods</h2>


  <div class="legend">
        <span class="key publickey"></span><span>Public</span>
        <span class="key protectedkey"></span><span>Protected</span>
        <span class="key privatekey"></span><span>Private</span>
  </div>







<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_labs_mock_MockManager_.html">
              goog.labs.mock.MockManager_
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.labs.mock.MockManager_.prototype.addBinding"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">addBinding<span class="args">(<span class="arg">methodName</span>,&nbsp;<span class="arg">args</span>,&nbsp;<span class="arg">func</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Adds a binding for the method name and arguments to be stubbed.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">methodName</span>
        : <div class="fullType">(<span class="type">null</span><span>&nbsp;|&nbsp;</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>)</div>
        <div class="entryOverview">The name of the stubbed method.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">args</span>
        : <div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span></div>
        <div class="entryOverview">The arguments passed to the method.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">func</span>
        : <div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span></div>
        <div class="entryOverview">The stub function.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_labs_mock_mock.js.source.html#line209">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry protected">
       <td class="access"></td>






  <td>
    <a name="goog.labs.mock.MockManager_.prototype.executeStub"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">executeStub<span class="args">(<span class="arg">methodName</span>,&nbsp;<span class="arg">var_args</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type">*</span></div>
      </div>


     <div class="entryOverview">
       Looks up the list of stubs defined on the mock object and executes the
function associated with that stub.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">methodName</span>
        : <div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
        <div class="entryOverview">The name of the method to execute.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">var_args</span>
        : <div class="fullType"><span>?</span></div>
        <div class="entryOverview">The arguments passed to the method.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type">*</span></div>&nbsp;
            Value returned by the stub function.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_labs_mock_mock.js.source.html#line256">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry protected">
       <td class="access"></td>






  <td>
    <a name="goog.labs.mock.MockManager_.prototype.findBinding"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">findBinding<span class="args">(<span class="arg">methodName</span>,&nbsp;<span class="arg">args</span>)</span>
        </span>
        &#8658; <div class="fullType">(<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span>)</div>
      </div>


     <div class="entryOverview">
       Returns a stub, if defined, for the method name and arguments passed in.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">methodName</span>
        : <div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
        <div class="entryOverview">The name of the stubbed method.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">args</span>
        : <div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span></div>
        <div class="entryOverview">The arguments passed to the method.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType">(<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span>)</div>&nbsp;
            The stub function or undefined.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_labs_mock_mock.js.source.html#line224">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry protected">
       <td class="access"></td>






  <td>
    <a name="goog.labs.mock.MockManager_.prototype.getExecutor"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">getExecutor<span class="args">(<span class="arg">methodName</span>,&nbsp;<span class="arg">args</span>)</span>
        </span>
        &#8658; <div class="fullType">(<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span>)</div>
      </div>


     <div class="entryOverview">
       Returns a stub, if defined, for the method name and arguments passed in as
parameters.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">methodName</span>
        : <div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
        <div class="entryOverview">The name of the stubbed method.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">args</span>
        : <div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span></div>
        <div class="entryOverview">The arguments passed to the method.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType">(<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span>)</div>&nbsp;
            The stub function or undefined.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_labs_mock_mock.js.source.html#line242">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.labs.mock.MockManager_.prototype.getMockedItem"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">getMockedItem<span class="args">()</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span></div>
      </div>


     <div class="entryOverview">
       Returns the mock object. This should have a stubbed method for each method
on the object being mocked.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span></div>&nbsp;
            The mock object.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_labs_mock_mock.js.source.html#line196">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>






  <td>
    <a name="goog.labs.mock.MockManager_.prototype.handleMockCall_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">handleMockCall_<span class="args">(<span class="arg">methodName</span>,&nbsp;<span class="arg">var_args</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="class_goog_labs_mock_StubBinder_.html">goog.labs.mock.StubBinder_</a></span></div>
      </div>


     <div class="entryOverview">
       Handles the first step in creating a stub, returning a stub-binder that
is later used to bind a stub for a method.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">methodName</span>
        : <div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
        <div class="entryOverview">The name of the method being bound.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">var_args</span>
        : <div class="fullType"><span>?</span></div>
        <div class="entryOverview">The arguments to the method.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="class_goog_labs_mock_StubBinder_.html">goog.labs.mock.StubBinder_</a></span></div>&nbsp;
            The stub binder.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_labs_mock_mock.js.source.html#line183">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.labs.mock.MockManager_.prototype.recordCall_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">recordCall_<span class="args">(<span class="arg">methodName</span>,&nbsp;<span class="arg">args</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Records a call to 'methodName' with arguments 'args'.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">methodName</span>
        : <div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
        <div class="entryOverview">The name of the called method.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">args</span>
        : <div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span></div>
        <div class="entryOverview">The array of arguments.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_labs_mock_mock.js.source.html#line277">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry protected">
       <td class="access"></td>






  <td>
    <a name="goog.labs.mock.MockManager_.prototype.verifyInvocation"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">verifyInvocation<span class="args">(<span class="arg">methodName</span>,&nbsp;<span class="arg">var_args</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span></div>
      </div>


     <div class="entryOverview">
       Verify invocation of a method with specific arguments.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">methodName</span>
        : <div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
        <div class="entryOverview">The name of the method.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">var_args</span>
        : <div class="fullType"><span>?</span></div>
        <div class="entryOverview">The arguments passed.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span></div>&nbsp;
            The stub, if defined, or the spy method.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_labs_mock_mock.js.source.html#line294">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>




<h2>Instance Properties</h2>







<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_labs_mock_MockObjectManager_.html">
              goog.labs.mock.MockObjectManager_
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.labs.mock.MockObjectManager_.prototype.objectCallVerifier_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">objectCallVerifier_</span>
        : <div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>.&lt;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>,<span class="type">function (string</span>,<span>?</span><span class="type"> ...[?]): </span>&gt;</div>
     </div>


     <div class="entryOverview">
       The call verifier is used to verify the calls. It maps property names to
the method that does call verification.
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_labs_mock_mock.js.source.html#line338">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>

<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_labs_mock_MockManager_.html">
              goog.labs.mock.MockManager_
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.labs.mock.MockManager_.prototype.callRecords_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">callRecords_</span>
        : <div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span>.&lt;<span class="type"><a href="class_goog_labs_mock_MethodBinding_.html">goog.labs.mock.MethodBinding_</a></span>&gt;</div>
     </div>


     <div class="entryOverview">
       Record method calls with no stub definitions.
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_labs_mock_mock.js.source.html#line170">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry protected">
       <td class="access"></td>





  <a name="goog.labs.mock.MockManager_.prototype.mockedItem"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">mockedItem</span>
        : <div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span></div>
     </div>


     <div class="entryOverview">
       Proxies the methods for the mocked object or class to execute the stubs.
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_labs_mock_mock.js.source.html#line144">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry protected">
       <td class="access"></td>





  <a name="goog.labs.mock.MockManager_.prototype.mockee"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">mockee</span>
        : <div class="fullType">(<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span>)</div>
     </div>


     <div class="entryOverview">
       A reference to the object or function being mocked.
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_labs_mock_mock.js.source.html#line151">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>




<h2>Static Methods</h2>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.labs.mock.MockObjectManager_.call"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.labs.mock.MockObjectManager_.</span><span class="entryName">call<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

   
  </td>


  <td class="view-code">
     <a href="closure_goog_labs_mock_mock.js.source.html#line320">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>









<div class="section">
  <table class="horiz-rule">


  </table>
</div>









<div class="section">
  <table class="horiz-rule">


  </table>
</div>
      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Package labs.mock</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">Package Reference</h2>
            <div id="sideTypeIndex" rootPath="" current="labs.mock.MockObjectManager_"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
